<template>
  <div class="home">
    <!-- <ul>
      <router-link tag="li" to="/page1">page1</router-link>
      <router-link tag="li" to="/page2">page2</router-link>
      <router-link tag="li" to="/page3">page3</router-link>
      <router-link tag="li" to="/page4">page4</router-link>
    </ul> -->
    这是个动物园
    <button @click="goBuy">去买票</button>
    <ul>
      <li @click="goPage('page1')">猴子</li>
      <li @click="goPage('page2')">斑马</li>
      <li @click="goPage('page3')">老虎</li>
      <li @click="goPage('page4')">熊猫</li>
    </ul>
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  name: 'Home',
  methods: {
    goPage(name) {
      this.$router.push({
        name
      })
      // this.$router.push('/page1?id=123&name=zhangsan')
      // replace 替换当前路由 是当前路由不会存在历史中
      // this.$router.replace({
      //   name
      // })
    },

    goBuy() {
      this.$router.push('/about')
    }
  }
}
</script>
<style scoped>
  ul{
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: space-between;
  }
  li{
    padding: 10px 15px;
  }
</style>
